package utils

import org.apache.spark.rdd.RDD
import redis.clients.jedis.Jedis

/**
  * Created by 王康 on 2018/6/30.
  */
object ReditsUtils {
  def putApp_dict2Redis(file: RDD[String]): Unit = {
    file.map(t => t.split("\t")).filter(t =>
      t.length >= 5
        && !t(4).isEmpty)
      .map(t => (t(4), t(1))).foreachPartition(it => {
      val jedis: Jedis = JedisPools.getJedis()
      it.foreach(t => {
        jedis.hset("Media_analysis_Redis", t._1, t._2)
      })
      jedis.close()
    })
  }
}


